<template>
    <view>
        <image class="back" src="../../static/images/jpg01.jpg" mode="widthFix"></image>
        <view class="main">
            <view class="login">
                <view class="h1">进销存</view>
                <view class="form">
                    <input placeholder="请输入账号" v-model="mobile">
                    <input password placeholder="请输入密码" v-model="password">
                    <!--<view class="select">
                        <input type="password" placeholder="请选择地区" v-model="password">
                        <image src="../../static/images/icon09.png"></image>
                    </view>-->
                    <view class="btn" @click="submit">登录</view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import {
        login,
        userInfo
    } from '../../api/api'
    export default {
        data() {
            return {
                mobile:'',
                password:'',
            }
        },
        onLoad() {

        },
        methods: {
            submit(){
                if(this.mobile == ''){
                    return uni.showToast({
                        title:'请输入账号',
                        icon:'none'
                    })
                }
                if(this.password == ''){
                    return uni.showToast({
                        title:'请输入密码',
                        icon:'none'
                    })
                }
                login({
                    mobile:this.mobile,
                    password:this.password,
                }).then(res => {
                    console.log(res);
                    uni.setStorageSync('token',res.data.token);
                    userInfo().then(res => {
                        uni.setStorageSync('userInfo',res.data);
                        this.$common.go(1,`/pages/selectCountry/index`)
                    })
                })
            }
        }
    }
</script>
<style>
    page{
        background: #f5f5f5;
    }
</style>
<style lang="scss" scoped>
    .back{
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
    }
    .main{
        width: 100%;
        height: 100vh;
        position: relative;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        .login{
            width: 640rpx;
            .h1{
                font-size: 45rpx;
                color: #222;
                text-align: center;
            }
            .form{
                padding-top: 65rpx;
                input{
                    width: 100%;
                    height: 100rpx;
                    border-radius: 100rpx;
                    background: #fff;
                    padding: 0 60rpx;
                    font-size: 30rpx;
                    color: #222;
                    box-sizing: border-box;
                    margin-top: 47rpx;
                }
                .select{
                    position: relative;
                    &:after{
                        content: '';
                        display: block;
                        width: 100%;
                        height: 100%;
                        position: absolute;
                        top: 0;
                        left: 0;
                        z-index: 2;
                    }
                    image{
                        width: 31rpx;
                        height: 18rpx;
                        transform: translateY(-50%);
                        position: absolute;
                        top: 50%;
                        right: 60rpx;
                    }
                }
                .btn{
                    height: 100rpx;
                    border-radius: 100rpx;
                    background: #f00;
                    text-align: center;
                    line-height: 100rpx;
                    font-size: 36rpx;
                    color: #fff;
                    margin-top: 100rpx;
                    background: #365aa6;
                }
            }
        }
    }
</style>
